package boot.service.impl.order;

import boot.controller.Shopping.order;
import boot.dao.OrderMapper;
import boot.domain.order.Order;
import boot.domain.wxGoodsCategory.GoodscategoryExample;
import boot.service.orderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;


@Service
public class orderServiceImpl implements orderService {
    @Autowired
    private OrderMapper orderMapper;

    @Override
    public int createOrder(int userId,StringBuilder cartsId) {
        try {
            Date date = new Date();
            Order order = new Order(null,userId,cartsId.toString(), date);
            orderMapper.insert(order);
            return 1;
        }catch (Exception e){
            e.printStackTrace();
            return 0;
        }

    }

    @Override
    public List<Order> getAllOrder(int userId) {
        return orderMapper.getAllOrder(userId);
    }
}
